import request from '@/plugins/request'
import { IResponseData } from '@/types/request-base'
import { json2FormData } from '@/utils'

// 立面相关接口

/**
 * 异常信息保存  SAID为00000000-0000-0000-0000-000000000000新增 AbnormalFiles对象为数组,AFID为00000000-0000-0000-0000-000000000000新增
 * @param {string} data  保存参数对象
 */
export function saveAbnormal(data: any) {
  if (!data.said) {
    data.said = '00000000-0000-0000-0000-000000000000'
  }
  data.abnormalFiles.forEach((v: any) => {
    if (!v.afid) {
      v.afid = '00000000-0000-0000-0000-000000000000'
    }
  })
  return request<IResponseData>({
    method: 'POST',
    url: `/app/TaskManage/SaveAcceptAbnormal`,
    data,
    headers: {
      repeatSubmit: false
    },
    loading: true,
    errorShow: true
  })
}

/**
 * 删除异常信息
 * @param {String} said  异常id
 */
export function deleteAbnormal(said: string) {
  return request<IResponseData>({
    method: 'POST',
    url: `/app/TaskManage/DeleteAcceptAbnormal`,
    params: { guid: said },
    errorShow: true
  })
}

/**
 * 删除异常问题信息
 * @param {String} sfid  异常问题id
 */
export function deleteAbnormalFile(sfid: string) {
  return request<IResponseData>({
    method: 'POST',
    url: `/app/TaskManage/DeleteAcceptAbnormalFile`,
    params: { guid: sfid },
    errorShow: true
  })
}

/**
 * 查询单个验收异常详情
 * @param {string} said 异常ID
 */
export function queryAbnormaDetail(said: string) {
  return request<IResponseData>({
    method: 'get',
    url: `/app/TaskManage/GetAcceptAbnormal?said=${said}`
  })
}
